import axios from 'axios';

const apiClient = axios.create({
    baseURL: '/api/accounts', // 基础路径设置为 /api/accounts
    timeout: 5000,
});

/**
 * 根据用户ID获取账户信息
 * 对应后端: GET /api/accounts/{userId}
 * @param {number} userId - 用户ID
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getAccountByUserId = (userId) => {
    return apiClient.get(`/${userId}`);
};

/**
 * 创建一个新账户
 * 对应后端: POST /api/accounts
 * @param {object} accountData - 账户信息
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const createAccount = (accountData) => {
    return apiClient.post('', accountData);
};